package com.qian.apiserver.service;

import com.qian.apiserver.model.OpenCard;
import com.qian.apiserver.service.IOpenCardService;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import com.yaowk.service.common.BaseRepository;
import com.qian.apiserver.dao.OpenCardDao;
import com.yaowk.service.common.BaseServiceImpl;
import java.lang.Integer;
import com.qian.apiserver.entity.GmOpenCard;

public abstract class OpenCardServiceBase extends BaseServiceImpl<OpenCard, GmOpenCard, Integer> implements IOpenCardService {

	@Autowired
	private OpenCardDao dao;

	@Override protected OpenCardDao getDao() {
	return dao;
	}

	@Override
	protected OpenCard entity2model(GmOpenCard entity) {
		OpenCard model = null;
		if(isNotEmpty(entity)){
			model = new OpenCard();
			model.setId(entity.getId());
			model.setCard1(entity.getCard1());
			model.setCard2(entity.getCard2());
			model.setCard3(entity.getCard3());
			model.setCard4(entity.getCard4());
			model.setCard5(entity.getCard5());
			model.setCard6(entity.getCard6());
			model.setCard7(entity.getCard7());
			model.setCard8(entity.getCard8());
			model.setCard9(entity.getCard9());
			model.setTime(entity.getTime());
		}
		return model;
	}

	@Override
	protected GmOpenCard model2Entity(OpenCard model) {
		GmOpenCard entity = null;
		if(isNotEmpty(model)){
			entity = new GmOpenCard();
			entity.setId(model.getId());
			entity.setCard1(model.getCard1());
			entity.setCard2(model.getCard2());
			entity.setCard3(model.getCard3());
			entity.setCard4(model.getCard4());
			entity.setCard5(model.getCard5());
			entity.setCard6(model.getCard6());
			entity.setCard7(model.getCard7());
			entity.setCard8(model.getCard8());
			entity.setCard9(model.getCard9());
			entity.setTime(model.getTime());
		}
		return entity;
	}

	@Override
	protected GmOpenCard updateParams(OpenCard model) {
		GmOpenCard entity = dao.findOne(model.getId());
		if(isNotEmpty(model.getCard1()))
			entity.setCard1(model.getCard1());
		if(isNotEmpty(model.getCard2()))
			entity.setCard2(model.getCard2());
		if(isNotEmpty(model.getCard3()))
			entity.setCard3(model.getCard3());
		if(isNotEmpty(model.getCard4()))
			entity.setCard4(model.getCard4());
		if(isNotEmpty(model.getCard5()))
			entity.setCard5(model.getCard5());
		if(isNotEmpty(model.getCard6()))
			entity.setCard6(model.getCard6());
		if(isNotEmpty(model.getCard7()))
			entity.setCard7(model.getCard7());
		if(isNotEmpty(model.getCard8()))
			entity.setCard8(model.getCard8());
		if(isNotEmpty(model.getCard9()))
			entity.setCard9(model.getCard9());
		if(isNotEmpty(model.getTime()))
			entity.setTime(model.getTime());
		return entity;
	}


}